-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom futures executor with iced_futures
#164
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
They can be leveraged by shells to easily execute commands and track subscriptions.
This was referenced Jan 20, 2020
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #63.
Mainly, this PR introduces a configurable
Executor
associated type toApplication
by leveraging a new subcrate:iced_futures
.The
Executor
traitThe new
iced_futures
subcrate contains a newExecutor
trait which is meant to allow shells to use different runtimes in a generic way.Feature flags can be enabled to obtain an implementation of this trait for well-known executors (
thread-pool
,tokio
,async-std
, andwasm-bindgen-futures
for now). This allows users to easily opt-in and choose their preferred runtime.For instance, let's say we want to use a
tokio
runtime for ourApplication
. We simply addiced_futures
to our dependencies and enable thetokio
feature:And we just plug it into our
Application
:For convenience,
iced
provides anexecutor::Default
which should resolve toThreadPool
in native platforms.wasm-bindgen-futures
in the Web.This basically replicates the behavior until now. Of course, if you choose to use your own executor, then it's up to you to ensure things stay cross-platform.
Additional amenities
The new subcrate also includes a bunch of new useful types:
subscription::Tracker
, which can be used to track aSubscription
, spawn or close streams accordingly, and broadcast shell events.Runtime
, combining anExecutor
and asubscription::Tracker
. It can be used to easily spawn commands or run event subscriptions and get notified of the results!Command
andSubscription
types, which have been moved fromiced_core
.Self-contained examples
The
dev-dependencies
oficed
were getting out of hand. Most of the examples are very different and showcase distinct ways to use the library while combining it with other parts of the ecosystem.Because of this, it made sense to turn every example into a subcrate. As a consequence:
iced
has nodev-dependencies
now! 🎉tour
(the main featured example) only depends oniced
andenv_logger
.README
with a nice description and a GIF (I haven't recorded GIFs for all the examples yet!).